package com.alibaba.citrus.ots.forecast.common;

import com.alibaba.citrus.ots.common.log.ModuleEnum;
import com.alibaba.citrus.ots.common.util.SpringContextUtil;
import com.alibaba.citrus.ots.forecast.repository.DealLineWriteRepository;
import com.alibaba.cz.base.tool.log.Log;
import com.alibaba.cz.base.tool.log.model.OpLogModel;
import com.alibaba.cz.base.tool.log.model.OperatorType;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.lattice2.epoch.user.dto.LoginUser;
import com.epoch.app.bcots.model.dto.EmployeeGetCurrentLoginResponse;
import com.epoch.app.bcots.service.BcOtsService;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class LogUtils {
    private static final Log log = Log.getLogger(LogUtils.class);

    public static void printOperateLog(String mainOrderId, Integer type, String activeValue , LoginUser loginUser) {
        //EmployeeGetCurrentLoginResponse employeeGetCurrentLoginResponse = bcOtsService.employeeGetCurrentLogin();
        log.info("当前登陆人信息"+JSONObject.toJSONString(loginUser));
        OpLogModel.OpLogModelBuilder<String> builder = OpLogModel.builder();
        OpLogModel<String> opLogModel = builder.build();
        opLogModel.setModuleName(ModuleEnum.FORECAST_SALES.getModuleName());
        opLogModel.setModuleId(String.valueOf(ModuleEnum.FORECAST_SALES.getModuleId()));
        //ForecastOrderLogEnum 类型使用的枚举值，解析过程在纪元中
        opLogModel.setOperateType(type);
        opLogModel.setObjectId(mainOrderId);
        opLogModel.setObjectName("id");
        Map<String, String> map = new HashMap<>();
        map.put("name", loginUser.getRealName());
        map.put("active", activeValue);
        String logInfo = JSONObject.toJSONString(map);
        opLogModel.setFeatures(logInfo);
        opLogModel.setOperatorId(loginUser.getEmpId());
        opLogModel.setOperatorType(OperatorType.USER.getOperatorType());
        log.asyncMonitorObjectChangeV2(opLogModel);

    }
}
